﻿using System.Web.Http;
using ML.Entity;
using ML.IBusiness;

namespace ML.WebApi.Controllers
{
    /// <summary>
    /// 用户api接口
    /// </summary>
    [CrossSite]
    public class UserController : BaseApiController
    {
        private readonly IUserBusiness userBusiness;
        public UserController(IUserBusiness userBusiness)
        {
            this.userBusiness = userBusiness;
        }

        /// <summary>
        ///  前台已经使用此方法—根据主键Id查询可用的用户信息(密码不返回)
        /// </summary>
        /// <param name="id">用户Id</param>
        /// <returns></returns>
        [Route("api/user/getbyuserid")]
        [HttpGet]
        public IHttpActionResult GetByUserId(string id)
        {
            var data = userBusiness.GetByUserId(id);
            return Json(data);
        }

        /// <summary>
        /// 根据openId查询可用的用户信息(密码不返回)
        /// </summary>
        /// <param name="id">用户的openid</param>
        /// <returns></returns>
        [Route("api/user/getbyopenid")]
        [HttpGet]
        public IHttpActionResult GetByOpenId(string id)
        {
            var data = userBusiness.GetByOpenId(id);
            return Json(data);
        }
    }
}